ROOT_DIR := ./../..

MAKEFILE_PARA := $(ROOT_DIR)/Makefile.env
#EX_INCLUDE = 

include $(MAKEFILE_PARA)

all : $(SUBDIRS)
$(SUBDIRS) : ECHO
	$(MAKE) -C $@

ECHO : 
	@echo "Compiling " $(SUBDIRS) "..." 

TARGET1 = libkv_static.a
TARGET2 = libkv.so

OBJ_SRCS=$(wildcard *.c *.cc)
NODIR=$(notdir $(OBJ_SRCS))
OBJS=$(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(NODIR)))

CFLAGS += -std=c++11 -I $(ROOT_DIR)/src

LIBS += -lrocksdb -lsnappy -lz

all: $(TARGET1) $(TARGET2)
$(TARGET1) : $(OBJS) 
	$(AR) $@ $^
	mv $@ $(LIBOUT)

$(TARGET2) : $(OBJS)
	$(CXX) -shared  $(CXXFLAGS) $(LIBS) -o $@ $^
	mv $@ $(LIBOUT)

%.o : %.c 
	@echo "Compiling" $< "..."
	$(CC) $(CFLAGS) -c $^ -o $@

%.o : %.cc
	@echo "Compiling" $< "..."
	$(CC) $(CFLAGS) -c $^ -o $@
clean:
	rm -rf *.o
